#lang racket

(define (extract str)
 (substring str 4 7))

(extract "the cat out of the bag")

(define (msom xt ct)
  (let ([d (+ (- xt nw) (- ct nc))]
        [w-learning-rate 0.1]
        [c-learning-rate 0.1]
        [delta-nw (* d (- xt nw))]
        [delta-nc (* d (- ct nc))]
        [n-winner (position-of-min d)]
        [ct (- (get nw n-winner) (get nc n-winner))]
        )
    (msom xt ct)
    )
  )

xt = placeholder

ct = placeholder || 0

Nw = tf.Variable
Nc = tf.Variable

d = ( xt - N.w ) + ( ct - N.c )

delta_Nw = d * (xt - Nw)

delta_Nc = d * (ct - Nc)

train_msom = tf.group(
  tf.assign_add(Nw, delta_Nw),
  tf.assign_add(Nc, delta_Nc)
  )

Nwinner = position_of_min(d)

ct = Nw[Nwinner] - Nc[Nwinner]

sess.run(
    [train_msom, Nwinner, ct],
    {xt: 5, ct: new_ct}
    )
